-
Notifications
You must be signed in to change notification settings - Fork 24
Added Windows support #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
I have managed to run several commands like:
I'm using Windows 10. Some requirements to use this patch:
Unfortunately, I can't test on a clean system and am afraid of side effects that may happen. I would appreciate any help with testing. I do this in Draft because I don't know Lua and I hope someone can help me review my Lua code. Especially why I just can't make my nested substitute multiline? :\ |
autoload/arduino.vim
Outdated
@@ -47,6 +47,11 @@ function! arduino#InitializeConfig() abort | |||
endif | |||
if !exists('g:arduino_serial_cmd') | |||
let g:arduino_serial_cmd = 'screen {port} {baud}' | |||
if s:OS ==? 'Windows' | |||
let g:arduino_serial_cmd = 'arduino-cli monitor -p {port} --config baudrate={baud}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the arduino-cli supports reading the serial output now, we should just use this as the new default (provided s:has_cli
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is supported. In fact, I didn't know it wasn't supported before. I think it is a good idea to use it as default.
autoload/arduino.vim
Outdated
if s:OS ==? 'Windows' | ||
let found = split(system('pwsh -nop -c "arduino-cli board list | Select-String -Pattern \"^(COM\d) \" | ForEach-Object { $_.Matches.Value }"'), '\n') | ||
for port in found | ||
call add(ports, port) | ||
endfor | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer if you could call arduino-cli
directly so it doesn't rely on powershell. Do the ports appear in the json data if you run it like we do here?
vim-arduino/autoload/arduino.vim
Line 251 in 111db61
let boards_data = json_decode(system('arduino-cli board listall --format json')) |
If not, you could still just call arduino-cli board list
and the extract the information you want using matchlist()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense. I'm gonna change it.
let l:path = substitute(l:path, '{file}', substitute(expand('%:p'), '\', '/', 'g'), 'g') | ||
let l:path = substitute(l:path, '{project_dir}', substitute(expand('%:p:h'), '\', '/', 'g'), 'g') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what you mean when you say the nested substitutes are not working? What specifically isn't working about them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize for the confusion. Nested substitutions work fine. I will write another message about what is working as I not expecting.
I used this hack to make it work on Windows. I don't know why any path on Windows is composed using backslashes. Without changing slashes topmost substitute
interpreted '\U' sequence as a trigger to make the next characters UPPERCASE. But on Windows path quite often starts with the C:/User/<username>
prefix. That broke compiling and uploading.
What I meant is that
|
Also I noticed that
Do you have any ideas on how to solve this? Looks like |
What version of vim are you using? We're running the command like so vim-arduino/autoload/arduino.vim Line 98 in 111db61
and vim-arduino/autoload/arduino.vim Lines 13 to 21 in 111db61
Both of the terminal options should run the command inside a terminal. From the logs you pasted, it looks like you might have just been doing a raw shell execution |
Upload & Serial works for me now and it is a much better experience. |
NVIM v0.9.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Couple of small refactors requested
if g:arduino_use_cli | ||
let g:arduino_serial_cmd = 'arduino-cli monitor -p {port} --config baudrate={baud}' | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this into the if !exists('g:arduino_serial_cmd')
above (line 49). Move that check below this one, and then set it to be the default serial command if g:arduino_use_cli
if s:OS ==? 'Windows' | ||
let boards_data = json_decode(system('arduino-cli board list --format json')) | ||
for board in boards_data | ||
call add(ports, board['port']['address']) | ||
endfor | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have to be windows-only? It seems like this API should work on all platforms. We should put it behind a if g:arduino_use_cli
check, though. And also deduplicate any entries in the list.
Trying to solve that issue - #4